#ifndef _TPOOL_
#define _TPOOL_


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <pthread.h>
#include <string.h>
#include <strings.h>
#include <iostream>


typedef struct Event_{
	int id;
	int fd;
	char * opstr;
	void (*func)(char* opstr,int fd,char * reback);
}Event;

typedef struct ThreadPool_{
	int MAXN;
	int cnt;
	Event *task;
	int hd;
	int tail;
	int thr_cnt;
	int shutdown;
	pthread_t *thr;
	pthread_mutex_t pool_mutex;
	pthread_mutex_t write_mutex;
	pthread_cond_t empty_task;
	pthread_cond_t unempty_task;
}Tpool;


Tpool *create_threadpool(int size_thr,int size_maxtask);
void *thr_start(void *arg);
void thread_addtask(Tpool *tp,int fd,char * opstr,void (*taskfunc)(char *,int,char *));
void close_threadpool(Tpool *tp);


#endif
